﻿#ifndef PRODUCTSTANDARDITEMMODEL_H
#define PRODUCTSTANDARDITEMMODEL_H

#include <QStandardItemModel>
#include "product.h"

class ProductStandardItemModel : public QStandardItemModel
{
    Q_OBJECT
public:
    explicit ProductStandardItemModel(QObject *parent = nullptr);

    QStringList header;

    void insertProduct(Product &product);

    void insertProduct(QList<Product*> products);

    void refreshTotalValue();

    Product* getProduct(int index);

    void reset();

signals:
    void updateTotalValue(int totalCount, int totalSanbao, double totalInPrice);

public slots:

private:
    int countIndex;
    int sanbaoIndex;
    int inPriceIndex;

    QList<Product*> products;
};

#endif // PRODUCTSTANDARDITEMMODEL_H
